# Makefile for NETCONF Agent project
#  
#   netconfd directory

############### SOURCE PROFILE ##############################

SUBDIR_NM=netconfd
SUBDIR_CPP=

############### TARGET PROFILE ##############################

TARGET=$(TBASE)/$(SUBDIR_NM)
BIN_INST=$(TBASE)/bin
REAL_INST=$(DESTDIR)$(PREFIX)/sbin

ifdef FREEBSD
LIB_INST=$(DESTDIR)$(PREFIX)/lib/yuma
else
ifdef LIB64
LIB_INST=$(DESTDIR)$(PREFIX)/lib64/yuma
else
LIB_INST=$(DESTDIR)$(PREFIX)/lib/yuma
endif
endif
PROG=netconfd

##################### LIBRARIES ########################

# The order of these LIBS matters!
#
# If the linker can't find external symbols you know should
# be there and you get an Unresolved External error 
#   file foo : unresolved external to bar
# Then put the library that contains 'foo' BEFORE the one
# that contains 'bar'. 
# The ncx library should be last 'internal' library

LIBS = 	-lagt -lncx -lxml2 -lz -lm

ifndef FREEBSD
LIBS += -ldl
endif

LIBTARGS= $(LBASE)/libagt.$(LIBNCXSUFFIX) $(LBASE)/libncx.$(LIBNCXSUFFIX)

############################# MAKE RULES ##################
ifdef DEVELOPER
all:
else
all: netconfd
endif  # DEVELOPER

#################### PLATFORM DEFINITIONS ############
include ../platform/platform.profile

################ DEPENDENCIES #########################
# depend rule must be included after the 'all' make rule

include ../platform/platform.profile.depend

ifneq ($(YUMA_CXX_BUILD),)
CFLAGS+= -x c++ 
LFLAGS+= -x none
endif

clean:
	rm -f $(OBJS) $(BIN_INST)/$(PROG)


superclean:
	rm -f *~ *.D dependencies $(OBJS) $(BIN_INST)/$(PROG)

test:


install:
ifndef DEVELOPER
	mkdir -p $(REAL_INST)
	mkdir -p $(LIB_INST)
	install $(OWNER) $(GRP) $(BIN_INST)/$(PROG) $(REAL_INST)
endif  # DEVELOPER

uninstall:
	rm -f  $(REAL_INST)/$(PROG)
	rm -rf $(LIB_INST)

distclean: superclean


# this real rule keeps make from deleting the $(OBJS) as
# intermediate files
netconfd: $(OBJS) $(LIBTARGS)
	$(LINK) $(CFLAGS) $(LFLAGS) -rdynamic $(OBJS) \
	-o $(BIN_INST)/$(PROG) $(LPATH) $(FPATH) $(LIBS)

.PHONY: netconfd

# prevent the make program from choking on all the symbols
# that get generated from autogenerated make rules
.NOEXPORT:

include ./dependencies
